#include <iostream>
#include <vector>
using namespace std;

class Solution {
public:
    void rotate(vector<int>& nums, int k) {
		if (nums.size() <= 1)
			return;
		k %= nums.size();
		if (!k)
			return;
		
		vector<int> iv(nums.end()-k,nums.end());/*
		iv.insert(iv.end(), nums.begin(), nums.end() - k);	
    	*/
		//vector<int> iv;
		//for (int i = nums.size()-k; i < nums.size(); ++i)
		//	iv.push_back(nums[i]);		
			
		for (int i = 0; i <=nums.size()-k-1; ++i)	
			iv.push_back(nums[i]);				
		nums = iv;        
    }
};

int main()
{
	vector<int> nums{ 1,2,3,4 };
	Solution().rotate(nums,1);
	for (auto i : nums)
		cout << i << " ";
	cout << endl;
	return 0;
}